package com.example.administrator.testapp;

import java.util.ArrayList;
import java.util.HashMap;


import android.annotation.SuppressLint;
import android.app.Activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;


public class InventorySetAntActivity extends Activity implements OnClickListener
{
	public static final int RESULT_OK = 1;
	public static final int RESULT_CANCEL = 2;

	Button btn_setparamall = null;
	CheckBox checkBoxall = null;
	CheckBox checkBox1 = null;
	CheckBox checkBox2 = null;
	CheckBox checkBox3 = null;
	CheckBox checkBox4 = null;
	CheckBox checkBox5 = null;
	CheckBox checkBox6 = null;
	CheckBox checkBox7 = null;
	CheckBox checkBox8 = null;
	CheckBox checkBox9 = null;
	CheckBox checkBox10 = null;
	CheckBox checkBox11 = null;
	CheckBox checkBox12 = null;
	CheckBox checkBox13 = null;
	CheckBox checkBox14 = null;
	CheckBox checkBox15 = null;
	CheckBox checkBox16 = null;

	EditText editText1 = null;
	EditText editText2 = null;
	EditText editText3 = null;
	EditText editText4 = null;
	EditText editText5 = null;
	EditText editText6 = null;
	EditText editText7 = null;
	EditText editText8 = null;
	EditText editText9 = null;
	EditText editText10 = null;
	EditText editText11 = null;
	EditText editText12 = null;
	EditText editText13 = null;
	EditText editText14 = null;
	EditText editText15 = null;
	EditText editText16 = null;

	CheckBox checkBox_tagfoucs = null;
	EditText editText_INVTIME = null;
	EditText editText_INVCI = null;
	EditText editText_OUTWHILE = null;
	EditText editText_ANTDelayTime  = null;
	EditText editText_IDC_STATIC_ANTFinshTime  = null;
	CheckBox checkBox_heart = null;
	Spinner spinner_SESSION = null;
	Spinner spinner_target = null;
	Button button_OKK = null;
	Button button_Cancela = null;

	private CheckboxAdapter listAntAdapter = null;
	private int mAntCnt = 0;

	int[] m_nSetAntArryUI= new int[17];//保存UI值
	int[] m_nSetpoweraaUI = new int[17];
	int[] m_nSetpowerbbUI = new int[17];
	int TAGFOCUS;
	int ianttime; //天线盘存时间
	int iantcisu; //天线盘存次数
	int ioutwhilecisu; //循环周期次数(最外循环)(0-0xFFFFFFFF):
	int idelayantandant; //天线与天线间隔时间
	int idelayoutwhile;  //天线循环一圈与下一圈间隔时间
	byte iisheartpkg;  //是否需要心跳包，0--不需要，1--需要
	byte query_target; //A或B
	byte query_session; //S0,S1,S2,S3

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_parama);

		btn_setparamall = (Button) findViewById(R.id.btn_setparamall);
		btn_setparamall.setOnClickListener(this);

		checkBoxall = (CheckBox) findViewById(R.id.checkBoxall);
//		checkBoxall.setOnClickListener(this);
		checkBoxall.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
				if (b){
					checkBox1.setChecked(true);
					checkBox2.setChecked(true);
					checkBox3.setChecked(true);
					checkBox4.setChecked(true);
					checkBox5.setChecked(true);
					checkBox6.setChecked(true);
					checkBox7.setChecked(true);
					checkBox8.setChecked(true);
					checkBox9.setChecked(true);
					checkBox10.setChecked(true);
					checkBox11.setChecked(true);
					checkBox12.setChecked(true);
					checkBox13.setChecked(true);
					checkBox14.setChecked(true);
					checkBox15.setChecked(true);
					checkBox16.setChecked(true);
				}else{
					checkBox1.setChecked(false);
					checkBox2.setChecked(false);
					checkBox3.setChecked(false);
					checkBox4.setChecked(false);
					checkBox5.setChecked(false);
					checkBox6.setChecked(false);
					checkBox7.setChecked(false);
					checkBox8.setChecked(false);
					checkBox9.setChecked(false);
					checkBox10.setChecked(false);
					checkBox11.setChecked(false);
					checkBox12.setChecked(false);
					checkBox13.setChecked(false);
					checkBox14.setChecked(false);
					checkBox15.setChecked(false);
					checkBox16.setChecked(false);
				}
			}
		});

		checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
		checkBox1.setOnClickListener(this);
		checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
		checkBox2.setOnClickListener(this);
		checkBox3 = (CheckBox) findViewById(R.id.checkBox3);
		checkBox3.setOnClickListener(this);
		checkBox4 = (CheckBox) findViewById(R.id.checkBox4);
		checkBox4.setOnClickListener(this);

		checkBox5 = (CheckBox) findViewById(R.id.checkBox5);
		checkBox5.setOnClickListener(this);
		checkBox6 = (CheckBox) findViewById(R.id.checkBox6);
		checkBox6.setOnClickListener(this);
		checkBox7 = (CheckBox) findViewById(R.id.checkBox7);
		checkBox7.setOnClickListener(this);
		checkBox8 = (CheckBox) findViewById(R.id.checkBox8);
		checkBox8.setOnClickListener(this);

		checkBox9 = (CheckBox) findViewById(R.id.checkBox9);
		checkBox9.setOnClickListener(this);
		checkBox10 = (CheckBox) findViewById(R.id.checkBox10);
		checkBox10.setOnClickListener(this);
		checkBox11 = (CheckBox) findViewById(R.id.checkBox11);
		checkBox11.setOnClickListener(this);
		checkBox12 = (CheckBox) findViewById(R.id.checkBox12);
		checkBox12.setOnClickListener(this);

		checkBox13 = (CheckBox) findViewById(R.id.checkBox13);
		checkBox13.setOnClickListener(this);
		checkBox14 = (CheckBox) findViewById(R.id.checkBox14);
		checkBox14.setOnClickListener(this);
		checkBox15 = (CheckBox) findViewById(R.id.checkBox15);
		checkBox15.setOnClickListener(this);
		checkBox16 = (CheckBox) findViewById(R.id.checkBox16);
		checkBox16.setOnClickListener(this);

		editText1 = (EditText) findViewById(R.id.editText1);
		editText2 = (EditText) findViewById(R.id.editText2);
		editText3 = (EditText) findViewById(R.id.editText3);
		editText4 = (EditText) findViewById(R.id.editText4);

		editText5 = (EditText) findViewById(R.id.editText5);
		editText6 = (EditText) findViewById(R.id.editText6);
		editText7 = (EditText) findViewById(R.id.editText7);
		editText8 = (EditText) findViewById(R.id.editText8);

		editText9 = (EditText) findViewById(R.id.editText9);
		editText10 = (EditText) findViewById(R.id.editText10);
		editText11 = (EditText) findViewById(R.id.editText11);
		editText12 = (EditText) findViewById(R.id.editText12);

		editText13 = (EditText) findViewById(R.id.editText13);
		editText14 = (EditText) findViewById(R.id.editText14);
		editText15 = (EditText) findViewById(R.id.editText15);
		editText16 = (EditText) findViewById(R.id.editText16);

		checkBox_tagfoucs = (CheckBox) findViewById(R.id.checkBox_tagfoucs);
		editText_INVTIME = (EditText) findViewById(R.id.editText_INVTIME);
		editText_INVCI  = (EditText) findViewById(R.id.editText_INVCI);
		editText_OUTWHILE = (EditText) findViewById(R.id.editText_OUTWHILE);
		editText_ANTDelayTime = (EditText) findViewById(R.id.editText_ANTDelayTime);
		editText_IDC_STATIC_ANTFinshTime = (EditText) findViewById(R.id.editText_IDC_STATIC_ANTFinshTime);
		checkBox_heart = (CheckBox) findViewById(R.id.checkBox_heart);
		spinner_SESSION = (Spinner) findViewById(R.id.spinner_SESSION);
		spinner_target = (Spinner) findViewById(R.id.spinner_target);
		button_OKK = (Button) findViewById(R.id.button_OKK);
		button_OKK.setOnClickListener(this);
		button_Cancela = (Button) findViewById(R.id.button_Cancela);
		button_Cancela.setOnClickListener(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getExtras();
		int iSize = bundle.getInt("CMDGetAntSize");
		byte[] m_nRecBuf = bundle.getByteArray("CMDGetAnt");
		if ( 0 == iSize ){
			//default
		}else{
			//获取天线
			int itmppcnt = 0;
			checkBox1.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x80) > 7));
			checkBox2.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x40) > 6));
			checkBox3.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x20) > 5));
			checkBox4.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x10) > 4));

			checkBox5.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x08) > 3));
			checkBox6.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x04) > 2));
			checkBox7.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x02) > 1));
			checkBox8.setChecked((boolean) ((m_nRecBuf[5 + itmppcnt] & 0x01) > 0));

			checkBox9.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x80) > 7));
			checkBox10.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x40) > 6));
			checkBox11.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x20) > 5));
			checkBox12.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x10) > 4));

			checkBox13.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x08) > 3));
			checkBox14.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x04) > 2));
			checkBox15.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x02) > 1));
			checkBox16.setChecked((boolean) ((m_nRecBuf[6 + itmppcnt] & 0x01) > 0));

			editText1.setText(""+m_nRecBuf[7 + itmppcnt]);
			editText2.setText(""+m_nRecBuf[8 + itmppcnt]);
			editText3.setText(""+m_nRecBuf[9 + itmppcnt]);
			editText4.setText(""+m_nRecBuf[10 + itmppcnt]);

			editText5.setText(""+m_nRecBuf[11 + itmppcnt]);
			editText6.setText(""+m_nRecBuf[12 + itmppcnt]);
			editText7.setText(""+m_nRecBuf[13 + itmppcnt]);
			editText8.setText(""+m_nRecBuf[14 + itmppcnt]);

			editText9.setText(""+m_nRecBuf[15 + itmppcnt]);
			editText10.setText(""+m_nRecBuf[16 + itmppcnt]);
			editText11.setText(""+m_nRecBuf[17 + itmppcnt]);
			editText12.setText(""+m_nRecBuf[18 + itmppcnt]);

			editText13.setText(""+m_nRecBuf[19 + itmppcnt]);
			editText14.setText(""+m_nRecBuf[20 + itmppcnt]);
			editText15.setText(""+m_nRecBuf[21 + itmppcnt]);
			editText16.setText(""+m_nRecBuf[22 + itmppcnt]);

			//TAGFOCUS
			int dwTemp;
			dwTemp = m_nRecBuf[39 + itmppcnt];
			TAGFOCUS = dwTemp;
			if (TAGFOCUS == 0x00000010)
			{
				checkBox_tagfoucs.setChecked(true);
			}
			else
			{
				checkBox_tagfoucs.setChecked(false);
			}

			//天线盘存时间:(单位:ms)(0-3600000)
			dwTemp = 0;
			dwTemp |= ((m_nRecBuf[43 + itmppcnt] & 0xFF) << 0);
			dwTemp |= ((m_nRecBuf[44 + itmppcnt] & 0xFF) << 8);
			dwTemp |= ((m_nRecBuf[45 + itmppcnt] & 0xFF) << 16);
			dwTemp |= ((m_nRecBuf[46 + itmppcnt] & 0xFF) << 24);
			ianttime = dwTemp;

			editText_INVTIME.setText(""+ianttime);


			//天线盘存次数:(1-8192)
			dwTemp = 0;
			dwTemp |= ((m_nRecBuf[47 + itmppcnt] & 0xFF) << 0);
			dwTemp |= ((m_nRecBuf[48 + itmppcnt] & 0xFF) << 8);
			dwTemp |= ((m_nRecBuf[49 + itmppcnt] & 0xFF) << 16);
			dwTemp |= ((m_nRecBuf[50 + itmppcnt] & 0xFF) << 24);
			iantcisu = dwTemp;

			editText_INVCI.setText(""+iantcisu);


			//循环周期次数(最外循环)(0-0xFFFFFFFF):
			dwTemp = 0;
			dwTemp |= ((m_nRecBuf[51 + itmppcnt] & 0xFF) << 0);
			dwTemp |= ((m_nRecBuf[52 + itmppcnt] & 0xFF) << 8);
			dwTemp |= ((m_nRecBuf[53 + itmppcnt] & 0xFF) << 16);
			dwTemp |= ((m_nRecBuf[54 + itmppcnt] & 0xFF) << 24);
			ioutwhilecisu = dwTemp;

			editText_OUTWHILE.setText(""+ioutwhilecisu);

			//51-54第51~54字节代表天线与天线间隔时间(0一直循环),51代表低字节，54代表高字节
			//天线与天线间隔时间
			dwTemp = 0;
			dwTemp |= ((m_nRecBuf[55 + itmppcnt] & 0xFF) << 0);
			dwTemp |= ((m_nRecBuf[56 + itmppcnt] & 0xFF) << 8);
			dwTemp |= ((m_nRecBuf[57 + itmppcnt] & 0xFF) << 16);
			dwTemp |= ((m_nRecBuf[58 + itmppcnt] & 0xFF) << 24);
			idelayantandant = dwTemp;

			editText_ANTDelayTime.setText(""+idelayantandant);

			//天线循环一圈与下一圈间隔时间
			dwTemp = 0;
			dwTemp |= ((m_nRecBuf[59 + itmppcnt] & 0xFF) << 0);
			dwTemp |= ((m_nRecBuf[60 + itmppcnt] & 0xFF) << 8);
			dwTemp |= ((m_nRecBuf[61 + itmppcnt] & 0xFF) << 16);
			dwTemp |= ((m_nRecBuf[62 + itmppcnt] & 0xFF) << 24);
			idelayoutwhile = dwTemp;

			editText_IDC_STATIC_ANTFinshTime.setText(""+idelayoutwhile);

			//是否需要心跳包(打勾需要)
			dwTemp = m_nRecBuf[63 + itmppcnt];
			iisheartpkg = (byte)dwTemp;
			if (iisheartpkg == 1)
			{
				checkBox_heart.setChecked(true);
			}
			else
			{
				checkBox_heart.setChecked(false);
			}

			//TARGET
			dwTemp = m_nRecBuf[64 + itmppcnt];
			query_target = (byte)dwTemp;
			spinner_target.setSelection(query_target);

			//SESSION
			dwTemp = m_nRecBuf[65 + itmppcnt];
			query_session = (byte)dwTemp;
			spinner_SESSION.setSelection(query_session);



		}


	}

	@Override
	public void onClick(View v)
	{
		switch (v.getId())
		{
			case R.id.btn_setparamall:
				if (true){
					String strTemp;
					strTemp = editText1.getText().toString();
					editText2.setText(strTemp);
					editText3.setText(strTemp);
					editText4.setText(strTemp);

					editText5.setText(strTemp);
					editText6.setText(strTemp);
					editText7.setText(strTemp);
					editText8.setText(strTemp);

					editText9.setText(strTemp);
					editText10.setText(strTemp);
					editText11.setText(strTemp);
					editText12.setText(strTemp);

					editText13.setText(strTemp);
					editText14.setText(strTemp);
					editText15.setText(strTemp);
					editText16.setText(strTemp);

				}
				break;

			case R.id.button_OKK:{
				Intent intent = new Intent();
				Bundle bundle = new Bundle();

				int iSize = 1;
				byte[] m_nRecBuf = new byte[67];

				//设置天线
				int ii = 0;
				int []x = new int[16];
				int dwTemp = 0;
				byte bcceck = 0;
				byte []bAnt = new byte[2];

				int k = 0;
				//天线盘存时间:(单位:ms)(0-3600000)
				k = (int)Integer.parseInt(editText_INVTIME.getText().toString());
				if (k < 0)
				{
					k = 0;
				}
				if (k > 3600000)
				{
					k = 3600000;
				}
				ianttime = k;

				//天线盘存次数:(1-8192)
				k = (int)Integer.parseInt(editText_INVCI.getText().toString());
				if (k < 1)
				{
					k = 1;
				}
				if (k > 8192)
				{
					k = 8192;
				}
				iantcisu = k;

				//循环周期次数(最外循环)(0-0xFFFFFFFF):
				k = (int)Integer.parseInt(editText_OUTWHILE.getText().toString());
				if (k < 0)
				{
					k = 0;
				}
				if (k > 0xFFFFFFF)
				{
					k = 0xFFFFFFF;
				}

				ioutwhilecisu = k;

				//TAGFOCUS
				if (checkBox_tagfoucs.isChecked())
				{
					TAGFOCUS = 0x00000010;
				}
				else
				{
					TAGFOCUS = 0x00000000;
				}

				//天线先中有哪些
				//m_nSetAntArryUI[0] = checkBox3.Checked ? 1 : 0; //天线 //这种方法也可以的

				m_nSetAntArryUI[0] = (int)(checkBox1.isChecked()?1:0); //天线1
				m_nSetAntArryUI[1] = (int)(checkBox2.isChecked()?1:0); //天线2
				m_nSetAntArryUI[2] = (int)(checkBox3.isChecked()?1:0); //天线3
				m_nSetAntArryUI[3] = (int)(checkBox4.isChecked()?1:0); //天线4

				m_nSetAntArryUI[4] = (int)(checkBox5.isChecked()?1:0); //天线5
				m_nSetAntArryUI[5] = (int)(checkBox6.isChecked()?1:0); //天线6
				m_nSetAntArryUI[6] = (int)(checkBox7.isChecked()?1:0); //天线7
				m_nSetAntArryUI[7] = (int)(checkBox8.isChecked()?1:0); //天线8

				m_nSetAntArryUI[8] = (int)(checkBox9.isChecked()?1:0); //天线9
				m_nSetAntArryUI[9] = (int)(checkBox10.isChecked()?1:0); //天线10
				m_nSetAntArryUI[10] =(int)(checkBox11.isChecked()?1:0); //天线11
				m_nSetAntArryUI[11] =(int)(checkBox12.isChecked()?1:0); //天线12

				m_nSetAntArryUI[12] = (int)(checkBox13.isChecked()?1:0); //天线13
				m_nSetAntArryUI[13] = (int)(checkBox14.isChecked()?1:0); //天线14
				m_nSetAntArryUI[14] = (int)(checkBox15.isChecked()?1:0); //天线15
				m_nSetAntArryUI[15] = (int)(checkBox16.isChecked()?1:0); //天线16

				m_nSetpoweraaUI[0] = (int)(int)Integer.parseInt(editText1.getText().toString());
				m_nSetpoweraaUI[1] = (int)(int)Integer.parseInt(editText2.getText().toString());
				m_nSetpoweraaUI[2] = (int)(int)Integer.parseInt(editText3.getText().toString());
				m_nSetpoweraaUI[3] = (int)(int)Integer.parseInt(editText4.getText().toString());

				m_nSetpoweraaUI[4] = (int)(int)Integer.parseInt(editText5.getText().toString());
				m_nSetpoweraaUI[5] = (int)(int)Integer.parseInt(editText6.getText().toString());
				m_nSetpoweraaUI[6] = (int)(int)Integer.parseInt(editText7.getText().toString());
				m_nSetpoweraaUI[7] = (int)(int)Integer.parseInt(editText8.getText().toString());

				m_nSetpoweraaUI[8] = (int)(int)Integer.parseInt(editText9.getText().toString());
				m_nSetpoweraaUI[9] = (int)(int)Integer.parseInt(editText10.getText().toString());
				m_nSetpoweraaUI[10] =(int)(int)Integer.parseInt(editText11.getText().toString());
				m_nSetpoweraaUI[11] =(int)(int)Integer.parseInt(editText12.getText().toString());

				m_nSetpoweraaUI[12] =(int)(int)Integer.parseInt(editText13.getText().toString());
				m_nSetpoweraaUI[13] =(int)(int)Integer.parseInt(editText14.getText().toString());
				m_nSetpoweraaUI[14] =(int)(int)Integer.parseInt(editText15.getText().toString());
				m_nSetpoweraaUI[15] =(int)(int)Integer.parseInt(editText16.getText().toString());

				for (ii = 0; ii < 16; ii++)
				{
					x[ii] = m_nSetAntArryUI[ii];
				}

				//天线与天线间隔时间
				k = (int)(int)Integer.parseInt(editText_ANTDelayTime.getText().toString());
				if (k < 0)
				{
					k = 0;
				}
				idelayantandant = k;

				//天线循环一圈与下一圈间隔时间
				k = (int)(int)Integer.parseInt(editText_IDC_STATIC_ANTFinshTime.getText().toString());
				if (k < 0)
				{
					k = 0;
				}
				idelayoutwhile = k;

				//是否需要心跳包
				if (checkBox_heart.isChecked())
				{
					iisheartpkg = 1;  //是否需要心跳包，0--不需要，1--需要
				}
				else
				{
					iisheartpkg = 0;  //是否需要心跳包，0--不需要，1--需要
				}

				query_target = (byte)spinner_target.getSelectedItemPosition();

				query_session = (byte)spinner_SESSION.getSelectedItemPosition();

				bAnt[0] = (byte) ( (x[0] << 7) | (x[1] << 6) | (x[2] << 5) | (x[3] << 4) | (x[4] << 3) | (x[5] << 2) | (x[6] << 1) | (x[7] << 0) );
				bAnt[1] = (byte) ( (x[8] << 7) | (x[9] << 6) | (x[10] << 5) | (x[11] << 4) | (x[12] << 3) | (x[13] << 2) | (x[14] << 1) | (x[15] << 0) );

				iSize = 0;
				m_nRecBuf[iSize++] = bAnt[0];
				m_nRecBuf[iSize++] = bAnt[1];

				for (ii = 0; ii < 16; ii++)
				{
					m_nRecBuf[iSize++] = (byte)m_nSetpoweraaUI[ii];
				}
				for (ii = 0; ii < 16; ii++)
				{
					m_nSetpowerbbUI[ii] = 30;
					m_nRecBuf[iSize++] = (byte)m_nSetpowerbbUI[ii];
				}

				dwTemp = TAGFOCUS;
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 8);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 16);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 24);

				dwTemp = ianttime;
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 8);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 16);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 24);

				dwTemp = iantcisu;
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 8);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 16);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 24);

				//ioutwhilecisu = 1; //循环周期次数(最外循环)(0-0xFFFFFFFF):
				dwTemp = ioutwhilecisu;
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 8);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 16);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 24);

				dwTemp = idelayantandant; //天线与天线间隔时间
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 8);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 16);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 24);

				dwTemp = idelayoutwhile; //天线循环一圈与下一圈间隔时间
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 8);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 16);
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 24);

				dwTemp = iisheartpkg; //
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);

				dwTemp = query_target; //
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);

				dwTemp = query_session; //
				m_nRecBuf[iSize++] = (byte)(dwTemp >> 0);

				bundle.putInt("CMDGetAntSize", iSize);
				bundle.putByteArray("CMDGetAnt", m_nRecBuf);
				intent.putExtras(bundle);
				this.setResult(RESULT_OK, intent);
				this.finish();
			}
			break;
			case R.id.button_Cancela:{
				this.finish();
			}
			break;
			default:
				//this.finish();
				break;
		}
	}


	public class CheckboxAdapter extends BaseAdapter
	{
		Context context;
		ArrayList<HashMap<String, Object>> listData;
		@SuppressLint("UseSparseArrays")
		HashMap<Integer, Boolean> state = new HashMap<Integer, Boolean>();

		public CheckboxAdapter(Context context,
							   ArrayList<HashMap<String, Object>> listData)
		{
			this.context = context;
			this.listData = listData;
		}

		public int getCount()
		{
			// TODO Auto-generated method stub
			return listData.size();
		}

		public Object getItem(int position)
		{
			// TODO Auto-generated method stub
			return listData.get(position);
		}

		public long getItemId(int position)
		{
			// TODO Auto-generated method stub
			return position;
		}

		// 重写View
		public View getView(final int position, View convertView,
							ViewGroup parent)
		{
			// TODO Auto-generated method stub

			return convertView;
		}
	}
}
